<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Java Web Monopoly Game</title>
	<link rel="stylesheet" href="css/loadPage.css">
    </head>
    <%
		// Get and Parse the Parameters
		String gameName = (String) request.getAttribute("gameName");
		String errMsg = (String) request.getAttribute("err_msg");
		Integer nPlayers, nhPlayers;
		Boolean bAutoDice;
		try {
		    nPlayers = (Integer) request.getAttribute("nPlayers");
		    nhPlayers = (Integer) request.getAttribute("nhPlayers");
		} catch (NumberFormatException e) {
		    nPlayers = 0;
		    nhPlayers = 0;
		}
		bAutoDice = (Boolean) request.getAttribute("autoDice");
    %>

    <script type="text/javascript" language="javascipt">
	function validateForm()
	{
	    var monopolyTitle = "Java Web Monopoly - Error"
	    if(document.frmJoin.playerName.value == "")
	    {
		jalert("Player Name Cannot be Empty!", monopolyTitle);
		document.frmJoin.playerName.focus();
		return false;
	    }
	    return true;
	}
    </script>


    <body>
	<div class="container">
	    <h1>Welcome to the Java Monopoly Game!</h1>
	    <h2>A Monopoly Game by Avia Tam and Assaf Miron</h2>
	    <BR>

	    <img src="img/monopoly-man.png" style="float:right;">
	    <H3>
		Would you like to <B>Join a Game?</B>
	    </H3>


	    <!--	<B><U>Game Details</U></B> -->



	    <div class="prices-table">

		<span class="left">Game Name:</span>
		<span class="right"><%=gameName%></span>

		<span class="left">Num. Of Players:</span>
		<span class="right"><%=nPlayers%></span>

		<span class="left">Num. of Human Players:</span>
		<span class="right"><%=nhPlayers%></span>

		<%if (bAutoDice) {%><span class="left" style="font-weight:normal;">Using Automatic Dice Mode</span>
		<%} else {%><span class="left" style="font-weight:normal;">Using Manual Dice Mode</span> <%}%>
	    </div>
	    <div style="clear: both;"></div>



	    <span id="errMsg" class="H1 error"></span>

	    <form method="post" action="MonopolyServlet" name="frmJoin" onSubmit="return validateForm()">

		<table cellspacing=1 cellpadding=3>
		    <tr>
			<td width="50%">Game Name:<BR> <input type="text"
							      name="gameName" id="txtGameName" value='<%=gameName%>' disabled="disabled"></td>
			<td width="50%">Player Name:<BR> <input type="text"
								name="playerName" id="txtPlayerName" value=''>
			</td>
		    </tr>
		    <tr colspan="2">
			<td><input type="checkbox" name="autoDice" id="chkAutoDice" disabled="disabled"
				   <%if (bAutoDice) {%> checked="checked" <%} else {%>""<%}%>>Automatic
					Dice Roll Mode</td>
		    </tr>
		    <tr>
			<td width="50%">Total Number of Players:<BR>
			    <input type="text" name="nPlayers" disabled="disabled" value='<%=nPlayers%>'></td>

			<td width="50%">Number of Human Players:<BR>
			    <input type="text" name="nhPlayers" disabled="disabled" value='<%=nhPlayers%>'></td>
		    </tr>
		    <tr>
			<td></td>
			<td><input type="submit" name="btnGo" id="btnGo"
				   class="button medium green" value='Join the Game'></td>
		    </tr>
		</table>
	    </form>
	</div>
    </body>
</html>